import Page
from Page import Carpark
from Base.Base import Base
from selenium.webdriver.common.by import By


class CarparkDialectErrorPage(Base):
    """
    车乐汇猜方言回答错误页

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 关闭按钮
        self.error_close_btn = (By.XPATH, Carpark.RESOURCE_ID_Dialect.format("iv_close"))

        # 猜歌名标题提示
        self.error_title_text = (By.XPATH, Carpark.RESOURCE_ID_Dialect.format("tv_question"))

        # 歌曲提示
        self.error_tip_text = (By.XPATH, Carpark.RESOURCE_ID_Dialect.format("tv_tip"))

        # 猜方言结果
        self.error_result_text = (By.XPATH, Carpark.RESOURCE_ID_Dialect.format("tv_result"))

        # 猜方言倒计时提示
        self.error_countdown_tip_text = (By.XPATH, Carpark.RESOURCE_ID_Dialect.format("tv_timer"))

        # 猜方言剩余血量图标
        self.error_remaining_blood_volume_icon = (By.XPATH, Carpark.RESOURCE_ID_Dialect.format("box_hearts"))

        # 第几题
        self.error_questions_text = (By.XPATH, Carpark.RESOURCE_ID_Dialect.format("tv_title"))

        # 暂停按钮
        self.error_stop_btn = (By.XPATH, Carpark.RESOURCE_ID_Dialect.format("iv_state"))

    def click_close(self):
        """
         点击关闭按钮

         :return:None
         """
        self.click_element(self.error_close_btn)

    def get_title(self):
        """
        获取回答题目标题

        :return:获取元素
        """
        return self.find_element_o(self.error_title_text)

    def get_tip(self):
        """
        获取猜方言提示

        :return:获取元素
        """
        return self.find_element_o(self.error_tip_text)

    def get_questions(self):
        """
        获取第几题文本

        :return:获取元素
        """
        return self.find_element_o(self.error_questions_text)

    def get_result(self):
        """
        获取猜方言结果文本

        :return:获取元素
        """
        return self.find_element_o(self.error_result_text)

    def get_countdown_tip(self):
        """
        获取猜方言倒计时文本

        :return:获取元素
        """
        return self.find_element_o(self.error_countdown_tip_text)

    def get_remaining_blood_volume(self):
        """
        获取猜方言剩余血量图标文本

        :return:获取元素
        """
        return self.find_element_o(self.error_remaining_blood_volume_icon)

    def click_stop(self):
        """
         点击暂停按钮

         :return:None
         """
        self.click_element(self.error_stop_btn)

    def is_display_carpark_error(self):
        """
        查看是否进入猜方言错误页面

        :return:
        """
        return self.is_display(self.error_result_text)
